<%- include ../include/header %>

      <div class="row marketing">

		<%- include ../include/flash %>

		<form role="form" method="post">
		
		  <div class="form-group">
		    <label for="inputTitle">Title</label>
		    <input type="text" class="form-control" id="inputTitle" name="title" value="<%= post.title %>">
		  </div>

            <div class="form-group">
                <label for="inputContent">Content</label> (Markdown supported)        
                <div class="wmd-panel">
                    <div id="wmd-button-bar"></div>
                    <textarea class="wmd-input form-control" id="wmd-input" name="content" rows="10"><%= post.content %></textarea>
                </div>
                <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
            </div>

		  <button type="submit" class="btn btn-default">Submit</button>

		</form>

      </div>

    <!-- Pagedown -->
    <script type="text/javascript" src="/vendor/pagedown/js/Markdown.Converter.js"></script>
    <script type="text/javascript" src="/vendor/pagedown/js/Markdown.Sanitizer.js"></script>
    <script type="text/javascript" src="/vendor/pagedown/js/Markdown.Editor.js"></script>
	<script type="text/javascript">
            (function () {
                var converter1 = Markdown.getSanitizingConverter();
                
                converter1.hooks.chain("preBlockGamut", function (text, rbg) {
                    return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function (whole, inner) {
                        return "<blockquote>" + rbg(inner) + "</blockquote>\n";
                    });
                });
                
                var editor1 = new Markdown.Editor(converter1);
                
                editor1.run();
                
                var converter2 = new Markdown.Converter();

                converter2.hooks.chain("preConversion", function (text) {
                    return text.replace(/\b(a\w*)/gi, "*$1*");
                });

                converter2.hooks.chain("plainLinkText", function (url) {
                    return "This is a link to " + url.replace(/^https?:\/\//, "");
                });
                
                var help = function () { alert("Do you need help?"); }
                var options = {
                    helpButton: { handler: help },
                    strings: { quoteexample: "whatever you're quoting, put it right here" }
                };
                var editor2 = new Markdown.Editor(converter2, "-second", options);
                
                editor2.run();
            })();
        </script>
<%- include ../include/footer %>